home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 991 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: jbuck@Synopsys.COM (Joe Buck)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: constness of private members and methods
  5. Date: 06 Apr 1996 11:33:45 PST
  6. Organization: Synopsys Inc., Mountain View, CA 94043-4033
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4k3q10$7bd@hermes.synopsys.com>
  9. References: <m0u3992-000GcEC@7.kurahaupo.gen.nz> <3161eaa4.8216104@nntp.ix.netcom.com> <4jvcrn$ch2@mule1.mindspring.com>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: 5 Apr 1996 18:50:08 GMT
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBVAwUBMWbHGky4NqrwXLNJAQFypgH8Dfhvx7gaLVb4kTo0FkhEzGVfvwU0VK4E
  14.     SYMrC3ta+P3KaEOriNiQTbGKm7eqW0sAlzBBOk91+D8Pvl+MEL/mVA==
  15.     =hTM+
  16. Originator: austern@isolde.mti.sgi.com
  17.  
  18. jdmorris@ix.netcom.com (Jason D. Morris) wrote:
  19. >>Assuming you allow 'pure' and 'clean', the compiler would then have
  20. >>to check to make sure your functions were in fact 'pure' and 'clean'.
  21.  
  22. abell@mindspring.com (Andrew Bell) writes:
  23. >The problem is the compiler needs to know the "purity" of the
  24. >functions a given function calls during its compilation, or it can't
  25. >optimize the code.  You would thus have to compile all the called
  26. >functions first,
  27.  
  28. No, you wouldn't.  Think of contractual programming, as in Eiffel.
  29. If a keyword associated with a prototype makes a promise (e.g. that
  30. a function has no side effects), users of that function can assume
  31. that promise is kept.  When the compiler compiles the "pure function",
  32. only then does it need to check the function for purity, using only
  33. local information.  No complex analysis is required: any function
  34. calls not so tagged would be assumed to be impure.
  35.  
  36. >With the proposed idea, a function that claims to pure and isn't would
  37. >be tagged with a compiler error.  This might be problematic with
  38. >templates, as instantiation for a particular type may lead to non-pure
  39. >functions being called.
  40.  
  41. Replace "pure" with "const".  It's no different.
  42. -- 
  43. -- Joe Buck     <jbuck@synopsys.com>    (not speaking for Synopsys, Inc)
  44.  
  45. Work for something because it is good,
  46. not just because it stands a chance to succeed.       -- Vaclav Havel
  47. ---
  48. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  49.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  50.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  51.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  52.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  53. ]
  54.